<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<script>

    $(function() {
        $("#butzt").click(function() {
            if ($("#ztfile1").val().length > 0) {
                ajaxFileUpload();
            } else {
                alert("请选择图片");
            }
        });
    });

    function ajaxFileUpload() {
        $.ajaxFileUpload({
            url : '${ctx}/tempimg', //用于文件上传的服务器端请求地址
            secureuri : false, //一般设置为false
            fileElementId : 'ztfile1', //文件上传空间的id属性  <input type="file" id="file" name="file" />
            type : 'post',
            dataType : 'HTML', //返回值类型 一般设置为json
            success  : function(data, status) //服务器成功响应处理函数
            {
                $("#ztimg1").attr("src", '${ctx}' + data);
                $("#ztpath").attr("value", data);
                if (typeof (data.error) != 'undefined') {
                    if (data.error != '') {
                        alert(data.error);
                    } else {
                        alert(data.msg);
                    }
                }
            },
            error : function(data, status, e)//服务器响应失败处理函数
            {
                alert(e);
            }
        })
        return false;
    }


    //上传拍照的图片
    function uploadziliao() {

//            alert("case_id是"+window.businesskey);
//            alert("证据是"+$('#ziliaolist option:selected').val());
//            alert("图片地址是"+$('#ztpath').val());
//            return false;

        if($('#ztpath').val().length > 0) {


            if ($('#ziliaolist option:selected').val() != '') {

                $.ajax({
                    type: "post",
                    url: getContextPath() + "/lzproof/picproofsave",
                    data: {
                        proofpath: $('#ztpath').val(),
                        case_id: window.businesskey,
                        prooftype:'${wstype}',
                        proofside:'${workflowtype}',
                        proofname: $('#ziliaolist option:selected').val()
                    },
                    dataType: "json",
                    success: function (data) {
                        if (data.success) {
                            var win4lasqb = $.messager.progress({
                                title: '提示',
                                msg: '照片正在上传中,请等待'
                            });


                            html = '';
                            var length = data.obj.length;
                            $("#rowspannum").attr("rowspan",length+1);
                            $(".appendsss").remove();
                            $.each(data.obj,function(index,item) {
                                html += '<tr class="appendsss">';

                                html += '<td colspan="2" style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-left-color:#000000; border-left-style:solid; border-left-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; padding-left:5.03pt; padding-right:5.03pt; vertical-align:top; width:34.25pt">'
                                html += '<p style="font-size:12pt; line-height:200%; margin:0pt; orphans:0; text-align:justify; widows:0">'
                                html += '<span style="font-family: Times New Roman; font-size:12pt">';
                                html += '<span style="font-family: Times New Roman; font-size:12pt">';
                                html += index + 1;
                                html += '</span>';
                                html += '</p>';
                                html += '</td>';

                                html += '<td colspan="5" style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-left-color:#000000; border-left-style:solid; border-left-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; padding-left:5.03pt; padding-right:5.03pt; vertical-align:top; width:178.2pt">';
                                html += '<p style="font-size:12pt; line-height:200%; margin:0pt; orphans:0; text-align:justify; widows:0">'
                                html += '<span style="font-family: Times New Roman; font-size:12pt">'
                                html += item.proofname;
                                html += '</span>';
                                html += '</p>';
                                html += '</td>';

                                html += '<td colspan="3" style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-left-color:#000000; border-left-style:solid; border-left-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; padding-left:5.03pt; padding-right:5.03pt; vertical-align:top; width:97.2pt">';
                                html += '<p style="font-size:12pt; line-height:200%; margin:0pt; orphans:0; text-align:justify; widows:0">'
                                html += '<span style="font-family: Times New Roman; font-size:12pt">'
                                html += '份';
                                html += '</span>'
                                html += '</p>'
                                html += '</td>';

                                html += '<td style="border-bottom-color:#000000; border-bottom-style:solid; border-bottom-width:0.75pt; border-left-color:#000000; border-left-style:solid; border-left-width:0.75pt; border-right-color:#000000; border-right-style:solid; border-right-width:0.75pt; border-top-color:#000000; border-top-style:solid; border-top-width:0.75pt; padding-left:5.03pt; padding-right:5.03pt; vertical-align:top; width:40.9pt">'
                                html += '<p style="font-size:12pt; line-height:200%; margin:0pt; orphans:0; text-align:justify; widows:0">';
                                html += '<span style="font-family: Times New Roman; font-size:12pt">';
                                var type;
                                if (item.proofname === '身份证照片') {
                                    type = 'sfzfyj';
                                } else if (item.proofname === '行驶证照片') {
                                    type = 'xszfyj';
                                } else if (item.proofname === '现场照片') {
                                    type = 'xczp';
                                } else if (item.proofname === '鉴定意见书照片') {
                                    type = 'jdyjs';
                                } else if (item.proofname === '实物证据照片') {
                                    type = 'swzj';
                                } else if (item.proofname === '试听资料') {
                                    type = 'stzl';
                                } else if (item.proofname === '营业执照照片') {
                                    type = 'yyzz';
                                } else if (item.proofname === '道路运输证照片') {
                                    type = 'dlysz';
                                } else if (item.proofname === '驾驶证照片') {
                                    type = 'jszfyj';
                                }
                                else if (item.proofname === '分流前磅单') {
                                    type = 'flqbd';
                                }
                                else if (item.proofname === '分流后磅单') {
                                    type = 'flhbd';
                                }
                                if (index > 2) {

                                    html += item.zjnums + '&nbsp;&nbsp;&nbsp;&nbsp;<a onclick=seeproofs("' + window.businesskey + '","' + type + '") style="cursor:pointer;"><i class="fa fa-eye" aria-hidden="true"></i></a>';
                                }else{
                                    html += item.zjnums ;
                                }
                                html += '</span>';
                                html += '</p>';
                                html += '</td>';

                                html += '</tr>';
                            });
                            $("#proofs").after("");
                            $("#proofs").after(html);

                            $.messager.progress('close');
                            $.messager.show({
                                title: '提示',
                                msg: '上传成功',
                                showType: 'slide',
                                style: {
                                    right: '',
                                    top: document.body.scrollTop + document.documentElement.scrollTop,
                                    bottom: ''
                                }
                            });



                            dynamic_ziliao.dialog('close');



                        }
                    }
                });
            } else {
                $.messager.show({
                    title: '提示',
                    msg: '请选择证据名称',
                    showType: 'slide',
                    style: {
                        right: '',
                        top: document.body.scrollTop + document.documentElement.scrollTop,
                        bottom: ''
                    }
                });
            }
        }else{
            $.messager.show({
                title: '提示',
                msg: '请先上传图片',
                showType: 'slide',
                style: {
                    right: '',
                    top: document.body.scrollTop + document.documentElement.scrollTop,
                    bottom: ''
                }
            });
        }

    }

</script>
<table class="table">
	<tr>
		<th>证据名称：</th>
		<td>
			<select id="ziliaolist">
				<%--<option value="现场笔录">现场笔录</option>--%>
				<%--<option value="勘验笔录">勘验笔录</option>--%>
				<%--<option value="询问笔录">询问笔录</option>--%>
				<option value="身份证照片">身份证照片</option>
				<option value="行驶证照片">行驶证照片</option>
				<option value="驾驶证照片">驾驶证照片</option>
				<option value="现场照片">现场照片</option>
				<option value="鉴定意见书照片">鉴定意见书照片</option>
				<option value="实物证据照片">实物证据照片</option>
				<option value="试听资料">试听资料</option>
				<option value="营业执照照片">营业执照照片</option>
				<option value="道路运输证照片">道路运输证照片</option>
					<option value="分流前磅单">分流前磅单</option>
					<option value="分流后磅单">分流后磅单</option>
			</select>
		</td>
	</tr>
	<tr>
		<th>资料图片：</th>
		<td>
			<input type="file" id="ztfile1" name="file" />
			<input type="button" id="butzt" value="上传">
			<input type="hidden" name="pliceTitle" id="ztpath">
			<img id="ztimg1" name="attpath"  width="160px" height="100px" src="">
		</td>
	</tr>

</table>